suppressPackageStartupMessages(library(tidyverse))
devtools::load_all('~/Google Drive/My Drive/Scripts/R_packages/myUtilities/')
## ℹ Loading myUtilities
wd <- '~/Google Drive/My Drive/Analysis/METTL2A/'
figdir <- paste0(wd, 'Figures/FLAG-IF/')
tabledir <- paste0(wd, 'Tables/FLAG-IF/')
Functions
paste_wd <- function(path) {
paste0(wd, path)
}
Read data
rename_col_and_reshape <- function(df) {
df |>
rename(distance_inches = `Distance_(inches)`) |>
pivot_longer(
cols = -c(distance_inches, sample),
names_to = 'channel', values_to = 'intensity'
)
}
ev_roi1 <-
read_csv('FLAG-2A_IF/FLAG4_ROI1.csv' |> paste_wd()) |>
mutate(sample = 'FLAG') |>
rename_col_and_reshape()
## Rows: 732 Columns: 4
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## dbl (4): Distance_(inches), mito, FLAG, DAPI
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
ev_roi1
## # A tibble: 2,196 × 4
## distance_inches sample channel intensity
## <dbl> <chr> <chr> <dbl>
## 1 0 FLAG mito 17.4
## 2 0 FLAG FLAG 0.730
## 3 0 FLAG DAPI 0
## 4 0.00333 FLAG mito 18.4
## 5 0.00333 FLAG FLAG 0.283
## 6 0.00333 FLAG DAPI 0
## 7 0.00667 FLAG mito 18.3
## 8 0.00667 FLAG FLAG 0.191
## 9 0.00667 FLAG DAPI 0
## 10 0.01 FLAG mito 17.4
## # ℹ 2,186 more rows
flag2a_roi2 <-
read_csv('FLAG-2A_IF/ROI2_250719.csv' |> paste_wd()) |>
mutate(sample = 'FLAG-2A') |>
rename_col_and_reshape()
## Rows: 754 Columns: 4
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## dbl (4): Distance_(inches), FLAG, Mito, DAPI
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
flag2a_roi2
## # A tibble: 2,262 × 4
## distance_inches sample channel intensity
## <dbl> <chr> <chr> <dbl>
## 1 0 FLAG-2A FLAG 0.344
## 2 0 FLAG-2A Mito 0.0006
## 3 0 FLAG-2A DAPI 0
## 4 0.00333 FLAG-2A FLAG 0.325
## 5 0.00333 FLAG-2A Mito 0
## 6 0.00333 FLAG-2A DAPI 0
## 7 0.00667 FLAG-2A FLAG 0.155
## 8 0.00667 FLAG-2A Mito 0
## 9 0.00667 FLAG-2A DAPI 0
## 10 0.01 FLAG-2A FLAG 0.009
## # ℹ 2,252 more rows
combined <-
bind_rows(ev_roi1, flag2a_roi2) |>
mutate(channel = str_replace(channel, 'mito', 'Mito'))
combined
## # A tibble: 4,458 × 4
## distance_inches sample channel intensity
## <dbl> <chr> <chr> <dbl>
## 1 0 FLAG Mito 17.4
## 2 0 FLAG FLAG 0.730
## 3 0 FLAG DAPI 0
## 4 0.00333 FLAG Mito 18.4
## 5 0.00333 FLAG FLAG 0.283
## 6 0.00333 FLAG DAPI 0
## 7 0.00667 FLAG Mito 18.3
## 8 0.00667 FLAG FLAG 0.191
## 9 0.00667 FLAG DAPI 0
## 10 0.01 FLAG Mito 17.4
## # ℹ 4,448 more rows
combined_lineplot <-
combined |>
ggplot(aes(
x = distance_inches, y = intensity,
color = channel
)) +
geom_line() +
scale_x_continuous(breaks = seq(0, 3, 1)) +
scale_color_manual(values = c('#7777ee', '#22aa22', '#aa22aa')) +
facet_wrap( ~ sample, axes = 'all')
combined_lineplot |>
ggsave_pdf(
width = 6, height = 4, outdir = figdir
)
